<template>
<div>
  <van-tabs v-model="active">
    <van-tab title="修改个人信息">
      <van-field v-model="userName" label="用户名" placeholder="请输入用户名"/>
      <van-field v-model="phonenumber" label="手机号" placeholder="请输入手机号"/>
      <van-field v-model="email" label="邮箱" placeholder="邮箱"/>
      <van-field v-model="remark" label="个人说明" type="email" placeholder="个人说明"/>
      <van-button type="info" style="width: 80%;margin-top: 30px; border-radius: 30px" @click="change">确认修改</van-button>
    </van-tab>
  </van-tabs>
</div>
</template>

<script>

import {getChangeinfo, getPersoninfo} from "@/api/api-Login";

export default {
  name: "ChangeUserinfo",
  data(){
    return{
      active:0,
      userName:"",
      phonenumber:"",
      email:"",
      remark:""
    }
  },
  methods:{
    change(){
      getChangeinfo(this.userName,this.email,this.phonenumber,this.remark).then(res=>{
        // console.log(res);
        this.$toast(res.msg)
        // console.log(this.userName)
        // this.$store.dispatch('login/getUserInfo')
      })
    }

  },
  created() {
    getPersoninfo().then(res=>{
      // console.log(res);
      if(res.code ==0) {
        this.userName = res.data.userName;
        this.phonenumber = res.data.phonenumber;
        this.email = res.data.email;
        this.remark = res.data.remark;
      }else {
        this.$toast("错误")
      }
    })
  }
}
</script>

<style scoped>

</style>